package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SysUserControllerApi;
import com.nineclock.system.dto.SysRegisterDTO;
import com.nineclock.system.dto.SysUserDTO;
import com.nineclock.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class SysUserController implements SysUserControllerApi {
    @Autowired
    SysUserService userService;

    @Override
    @PostMapping("/register")
    public Result register(SysRegisterDTO sysRegisterDTO) {
        Long id = userService.register(sysRegisterDTO);
        return Result.success(id);
    }

    @GetMapping("/query")
    public Result<SysUserDTO> queryUser(@RequestParam("username") String username){
        SysUserDTO sysUserDTO = userService.queryUser(username);
        return Result.success(sysUserDTO);
    }
}
